home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 5.7 KB | 198 lines | [TEXT/MPS ] |
- // UEvent.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
-
- #ifndef __UEVENT__
- #define __UEVENT__
-
- // MacApp
-
- #ifndef __UOBJECT__
- #include "UObject.h"
- #endif
-
- // Toolbox
-
- #ifndef __EVENTS__
- #include <Events.h>
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // Constants
- //----------------------------------------------------------------------------------------
-
- const short kPriorityLowest = 127;
- // Low priority commands are considered last
-
- const short kPriorityLow = kPriorityLowest - 32;
- // Low priority commands are considered last
-
- const short kPriorityNormal = 64;
- // Normal priority: command default priority
-
- const short kPriorityHigh = kPriorityNormal - 32;
- // High priority commands take precedence
-
- const short kPriorityHighest = 0;
- // High priority commands take precedence
-
-
- //----------------------------------------------------------------------------------------
- // Typedefs
- //----------------------------------------------------------------------------------------
-
- typedef char EventPriority;
- // Event priorities
-
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TEventHandler;
-
-
- //----------------------------------------------------------------------------------------
- // TEvent
- //----------------------------------------------------------------------------------------
-
- class TEvent : public TObject
- {
- MA_DECLARE_CLASS;
-
- public:
-
- TEvent();
- // Constructor
-
- virtual ~TEvent();
- // Write out a message if we are attempting to free an event that is still on the
- // event queue.
-
- void IEvent(EventNumber itsEventNumber,
- TEventHandler* itsSource,
- TEventHandler* itsHandler);
-
- virtual Boolean ShouldFreeOnCompletion();
-
- virtual Boolean IsReadyToPost();
- // True if the event can be posted to the event queue. Default returns true.
-
- virtual Boolean IsReadyToExecute();
-
- virtual Boolean IsRecurring();
-
-
- virtual TEventHandler* GetHandler();
-
- virtual void Process();
-
- #if qDebug
- virtual void ReportEvent();
- #endif
-
- //----------------------------------------------------------------------------------------
- // data members
- //----------------------------------------------------------------------------------------
- public:
- TEventHandler* fSource;
-
- TEventHandler* fHandler; // The handler for this event
-
- EventNumber fIdentifier; // Can be a many-to-one mapping of fIdentifier to
- // TEvent
-
- EventPriority fPriority; // How this event should be prioritized if
- // it has do compete on a prioritized
- // basis for execution. kNormalPriority is
- // the Default. Most programs won't have
- // to mess with this.
-
- Boolean fAffectsMenus; // True means the menus must be setup
- // after the event
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TToolboxEvent
- //----------------------------------------------------------------------------------------
-
- class TToolboxEvent : public TEvent
- {
- MA_DECLARE_CLASS;
-
- public:
- TToolboxEvent();
- // Constructor
-
- virtual ~TToolboxEvent();
- // Destructor
-
- Boolean IToolboxEvent(TEventHandler* itsHandler, const EventRecord& theEvent);
- // returns TRUE if the event was the first of a two event sequence
-
- void AddSecondaryKeyEvent(const EventRecord& theEvent);
-
- Boolean IsButtonPressed() const;
- // Was the button pressed?
-
- Boolean IsCommandKeyPressed() const;
- // Was Command key depressed?
-
- Boolean IsShiftKeyPressed() const;
- // Was Shift key depressed?
-
- Boolean IsAlphaLock() const;
- // Was Alpha Lock depressed?
-
- Boolean IsOptionKeyPressed() const;
- // Was Option key depressed?
-
- Boolean IsControlKeyPressed() const;
- // Was Control key depressed?
-
- Boolean IsAutoKeyEvent() const;
- // True if this was an auto key event
-
- virtual void Process(); //override
- // Call gApplication->DoToolBoxEvent directly to dispatch the event
-
- virtual Boolean RemoveDependenciesOnFree(); // override
- // TToolboxEvents don't have any dependents so do go through the overhead
-
- #if qDebug
- virtual void ReportEvent();
- #endif
-
- //----------------------------------------------------------------------------------------
- // data members
- //----------------------------------------------------------------------------------------
- public:
- EventRecord fEventRecords[2]; // IF a key event, The primary original
- // packed ToolBox event record (and secondary, when this is
- // a multibyte character)
-
- CStr2 fText; // IF a key event, the character that the event
- // translates to. length of 1 for single byte
- // characters and length of 2 for 16 bit characters
-
- const EventRecord& fEventRecord; // Reference to the first record, left in for compatibility
- const unsigned char& fCharacter; // Reference to the first character, left in for compatibility
-
- ScriptCode fKeyScript; // The KeyScript at the time the event was retrieved
-
- short fKeyCode; // IF a key event the virtual key code
- // that the event translates to
-
- short fClickCount; // 0 = event was not a mouse down; 1-N = #
- // of multiple clicks
- Boolean fDoubleEvent; // TRUE if there is a second event stored herein (fEventRecords[1])
- };
-
-
- #endif
-
-
-